﻿@using System.Web.Mvc.Ajax
@model  Matrix.MaKaYunShang.Model.McCashWithdrawApplication

@{
    ViewBag.Title = "提现操作";
    ViewBag.PathToBtn = "/Withdrawals/List";
    ViewBag.TextBtn = "返回至提现管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!-- /.row -->
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                提现信息
            </div>
            <div class="panel-body">
                <div class="row">

                    @using (Ajax.BeginForm("WithdrawOperation",
    new AjaxOptions { OnSuccess = "OnSuccess", OnFailure = "OnFailure", HttpMethod = "Post" }))
                    {

                        @*@using (Html.BeginForm("WithdrawOperation", "Withdrawals", FormMethod.Post, new { id = "frmCreate", enctype = "multipart/form-data" }))
                            {*@
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)

                        <div class="col-lg-12">
                            <fieldset>

                                <div class="form-group col-md-8">
                                    <label>银行名称</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.BankName, new { @class = "form-control", placeholder = "银行名称" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-8">
                                    <label>开户银行</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.BankOfDeposit, new { @class = "form-control", placeholder = "开户银行" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-8">
                                    <label>银行账户姓名</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.BankAccountName, new { @class = "form-control", placeholder = "银行账户姓名" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-8">
                                    <label>银行卡账户</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.BankAccount, new { @class = "form-control", placeholder = "银行卡账户" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-8">
                                    <label>提现金额</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.CashValue, new { @class = "form-control", placeholder = "提现金额" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-8">
                                    <label>备注</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.Remark, new { @class = "form-control", placeholder = "备注" })
                                        <span class="input-group-addon red"></span>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <button id="btnSave" type="button" class="btn btn-primary">确认并保存</button>
                                    <button id="btnReset" type="reset" class="btn btn-outline btn-primary">清空设置</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
                <!-- /.row (nested) -->
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->
@section javascript{
    <script type="text/javascript">
        $(function () {
            $("#form0").validate({
                rules: {
                    BankName: { required: true },
                    BankOfDeposit: { required: true },
                    BankAccountName: { required: true },
                    BankAccount: { required: true },
                    CashValue: { required: true, digits: true }
                },
                messages: {
                    BankName: { required: "请填写银行名称" },
                    BankOfDeposit: { required: "请填写开户银行" },
                    BankAccountName: { required: "请填写银行账户姓名" },
                    BankAccount: { required: "请填写银行卡账号" }
                   , CashValue: { required: "请填写提现金额" }
                }
            });

            $("#btnSave").click(function () {
                if ($("#form0").valid()) {
                    var userName = $("#UserName").val();
                    var accountId = 0;
                    $.ajax({
                        type: 'post',
                        async: false,
                        url: "/Withdrawals/WithdrawOperation",
                        data: { BankName: $("#BankName").val(),Remark:$("#Remark").val (),BankOfDeposit: $("#BankOfDeposit").val(), BankAccountName: $("#BankAccountName").val(), BankAccount: $("#BankAccount").val(), CashValue: $("#CashValue").val() },
                        success: function (info) {
                            if (info.Status == false) {
                                alertify.error(info.Message);
                            } else {
                                alertify.success(info.Message);
                                location.href = "/Withdrawals/List";
                            }
                        }
                    });
                }
            });
        });



        function OnSuccess(response) {

            alert(response.Data);
        }

        function OnFailure(response) {
            alert("服务器错误,提现失败!");
        }
    </script>
}